﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MapCenterSystem.DataInfo
{
    public class GraphNodeInfo : NodeInfo, IComparable<GraphNodeInfo>
    {
        int length;
        bool isRoot = false;
        public GraphNodeInfo()
        {
        }
        public GraphNodeInfo(GraphNodeInfo node)
        {
            this.Heuristic = node.Heuristic;
            this.function = node.Function;
            this.graphCost = node.GraphCost;
            this.Id = node.Id;
            this.IsRoot = node.IsRoot;
            this.Length = node.Length;
            this.Location = node.Location;
            this.Parent = node.Parent;
                
        }
        public int Length
        {
            get { return length; }
            set { length = value; }
        }

        public bool IsRoot
        {
            get { return isRoot; }
            set { isRoot = value; }
        }

        int graphCost = 0;

        public int GraphCost
        {
            get { return graphCost; }
            set { graphCost = value; }

        }
        int heuristic = 0;


        public int Heuristic
        {
            get { return heuristic; }
            set { heuristic = value; }
        }
        int function = 0;

        public int Function
        {
            get { return function; }
            set { function = value; }
        }
        GraphNodeInfo parent = null;

        public GraphNodeInfo Parent
        {
            get { return parent; }
            set { parent = value; }
        }

        public void PathScoring()
        {
            function = graphCost + heuristic;
        }

        public void MovementCost()
        {
            //GraphNodeInfo node = new GraphNodeInfo();
            //node.Parent = parent;
            //node.length = length;
            //while (!node.isRoot)
            //{
            //    graphCost += node.Length;
            //    node = node.Parent;
            //    if (node == null)
            //        return;
            //}
            graphCost = heuristic;
        }

        public override bool Equals(object obj)
        {
            GraphNodeInfo node = (GraphNodeInfo)obj;
            if (node.Id == id)
                return true;
            return false;
        }



        #region IComparable<GraphNodeInfo> Members

        public int CompareTo(GraphNodeInfo other)
        {
            if (other.Function == this.Function)
                return 0;
            if (other.Function < this.Function)
                return 1;
            return -1;
        }

        #endregion
    }
}
